<%@ page import="com.googlecode.monitoring.model.StateName" %>
<%@ page import="com.googlecode.monitoring.ws.model.WsItemToCheck" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="settings" scope="request" type="com.googlecode.monitoring.web.SettingsBean"/>
<jsp:useBean id="wsStatistic" scope="request" type="com.googlecode.monitoring.dao.StatisticDao"/>
<jsp:useBean id="dbAgentStatusBean" scope="request" type="com.googlecode.monitoring.web.DbAgentStatusBean"/>
<jsp:useBean id="wsAgentStatusBean" scope="request" type="com.googlecode.monitoring.web.WsAgentStatusBean"/>
<jsp:useBean id="flashAgentStatusBean" scope="request" type="com.googlecode.monitoring.web.FlashAgentStatusBean"/>
<jsp:useBean id="wsItems" scope="request" type="java.util.List<com.googlecode.monitoring.ws.model.WsItemToCheck>"/>

<html>
<head>
    <title>${title}</title>
    <style type="text/css" media="all">@import "styles/main.css";</style>
    <jsp:include page="autoRefreshHeader.jsp"/>
</head>
<body>

<jsp:include page="monitoringSummary.jsp"/>

<div class="singlePanel">

    <h2>WS Monitoring</h2>


    <%

        if (wsAgentStatusBean.isDataFound()) {

    %>

    <table>
        <tr>
            <th>Service Name</th>
            <th>Service Description</th>
            <th>State</th>
            <th>Statistic</th>
            <th>Last Check</th>
            <th>Next Check</th>
        </tr>
        <%

            for (WsItemToCheck wsItem : wsItems) {
        %>
        <tr <%=wsItem.getCurrentStateName().equals(com.googlecode.monitoring.model.StateName.EMAIL_SENT) ? "class=\"stateBad\"" : ""%>>
            <td class="nowrap"><%=wsItem.getName()%>
            </td>
            <td><%=wsItem.getDescr()%>
            </td>
            <td class="nowrap"><%=wsItem.getCurrentStateName().equals(com.googlecode.monitoring.model.StateName.EMAIL_SENT) ? "DOWN" : "up"%>
            </td>
            <td><%=wsStatistic.getPercentageUptimeForLastDays(wsItem.getId(),30)%>
            <td><%=wsItem.getLastCheckTime()%>
            <td><%=wsItem.getLastCheckTime()%>
        </tr>
        <%
            }

        %>
    </table>

    <%

        }

    %>
</div>

</body>
</html>